package com.fs.common.service.impl;

import com.fs.common.http.HttpHelper;
import com.fs.common.service.SendSmsService;
import com.fs.common.sms.enums.PassagewayEnum;
import com.fs.common.sms.utils.SmsUtils;
import com.fs.common.sms.vo.Passageway;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * @author DeveloperKK
 * @desc
 * @creationTime 2019-08-15 09:44
 * @projectName yuezi-menu
 * @packageName com.fs.common.service.impl
 */
@Service
public class SendSmsServiceImpl implements SendSmsService {

    private static final String SEND_URL= "http://111.47.110.68/api/SmSendServer";


    @Override
    public String sendVerificationCode(String account,String pwd,String mobile, String msg) {
        if (StringUtils.isNotBlank(account) && StringUtils.isNotBlank(pwd)
            && StringUtils.isNotBlank(mobile) && StringUtils.isNotBlank(msg) ) {
            Map<String,String> params = new HashMap<>();
            params.put("account",account);
            params.put("pwd",pwd);
            params.put("productId","4640086");
            params.put("mobile",mobile);
            params.put("msg",msg);
            return HttpHelper.Instance().httpPost(SEND_URL, params);
        }
        return null;
    }

    @Override
    public String sendAliyunVerificationCode(Passageway way) {
        return SmsUtils.send(PassagewayEnum.ALIBABA,way);
    }
}
